/**Created by the LayaAirIDE*/
module view{
	export class Start extends ui.StartUI{
		constructor(){
			super();
			this.on(Laya.Event.ADDED, this, this.onAdded);
			this.on(Laya.Event.REMOVED, this, this.onRemove);
		}

		Init():void{
			this.OnResize();
			this.login_ani.play();
        	this.balloon_ani.play();
			this.dcr_ani.play();
			// 加载资源
			if (Laya.Browser.onWeiXin) {
				Laya.URL.basePath = ServerCfg.ResUrl;
			}
			var resArray:Array<any> = [
				{url:"res/cfg/common.json", type:Laya.Loader.JSON},
				{url:"res/cfg/d_task.py.task.json", type:Laya.Loader.JSON},
				{url:"res/cfg/d_items.py.items.json", type:Laya.Loader.JSON},
				{url:"res/cfg/d_luckdarw.py.Prize_pool.json", type:Laya.Loader.JSON},   
            	{url:"res/cfg/d_sign.py.sign.json", type:Laya.Loader.JSON},    
            	{url:"res/cfg/d_sign.py.Rsign.json", type:Laya.Loader.JSON},     
				{url:"res/cfg/d_weather.py.weather.json", type:Laya.Loader.JSON},
				{url:"res/cfg/d_weather.py.disaster.json", type:Laya.Loader.JSON},
				{url:"res/cfg/d_share.py.share.json", type:Laya.Loader.JSON},
				{url:"res/cfg/d_mail.py.mails.json", type:Laya.Loader.JSON},
				{url:"res/cfg/d_prompt.py.prompts.json", type:Laya.Loader.JSON},
				{url:"res/atlas/main.atlas", type:Laya.Loader.ATLAS},
				{url:"res/atlas/crop.atlas", type:Laya.Loader.ATLAS},
				{url:"res/atlas/item.atlas", type:Laya.Loader.ATLAS},
				{url:"res/atlas/darw.atlas", type:Laya.Loader.ATLAS},
				{url:"res/atlas/task.atlas", type:Laya.Loader.ATLAS},
				{url:"res/atlas/mail.atlas", type:Laya.Loader.ATLAS},
				{url:"res/atlas/sign.atlas", type:Laya.Loader.ATLAS},
				{url:"res/atlas/sign/sign_pai.atlas", type:Laya.Loader.ATLAS},
				{url:"res/atlas/darw/anjian.atlas", type:Laya.Loader.ATLAS},
				{url:"res/atlas/rank.atlas", type:Laya.Loader.ATLAS},
				{url:"res/atlas/shield.atlas", type:Laya.Loader.ATLAS},
			];
			Laya.loader.load(resArray, new Laya.Handler(Game,Game.OnLoaded), Laya.Handler.create(this,this.onProgress,null,false));
		}

		OnResize() : void{
			let scalex = Laya.stage.width / Laya.stage.designWidth;
			let scaley = Laya.stage.height / Laya.stage.designHeight;
			this.scale(scalex, scaley);
		}

		onProgress(pro : number):void{
			this.progress_login.value = pro;
			this.progress_apple.x = this.progress_login.width * pro;
		}

		onAdded() : void{
			Laya.stage.on(Laya.Event.RESIZE, this, this.OnResize);
			this.Init();
		}

		onRemove() : void{
			Laya.stage.off(Laya.Event.RESIZE, this, this.OnResize);
		}
	}
}